local skel = fk.CreateSkill{
  name = "kqf__shushen",
}

Fk:loadTranslationTable{
  ["kqf__shushen"] = "淑慎",
  [":kqf__shushen"] = "当你失去最后一张手牌后，你可以令一名角色重铸三张牌，若不为你，其可改为摸三张牌并将此技能转移至其。",

  ["#kqf__shushen_choose"] = "淑慎：你可以令一名角色重铸三张牌，若不为你，其可改为摸三张牌并将此技能转移至其",
  ["#kqf__shushen_ask"] = "淑慎：重铸三张牌；或点“取消”以摸三张牌并将此技能转移至你",
  ["#kqf__shushen2_ask"] = "淑慎：重铸三张牌",

  ["$kqf__shushen1"] = "妾身亲做，望夫君莫要嫌弃。",
  ["$kqf__shushen2"] = "此物，或可解夫君一时之急。",
}

skel:addEffect(fk.AfterCardsMove, {
  can_trigger = function(self, event, target, player, data)
    if not (player:hasSkill(skel.name) and player:isKongcheng()) then return end
    for _, move in ipairs(data) do
      if move.from == player then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerHand then
            return true
          end
        end
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local playerlist = room.alive_players
    if #player:getCardIds{Player.Hand, Player.Equip} < 2 then
      table.removeOne(playerlist,player)
    end
    local to = room:askToChoosePlayers(player, {
      min_num = 1,
      max_num = 1,
      targets = room.alive_players,
      skill_name = skel.name,
      prompt = "#kqf__shushen_choose",
      cancelable = true,
    })
    if #to > 0 then
      event:setCostData(self, {tos = to})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).tos[1]
    local cards = to:getCardIds{Player.Hand, Player.Equip}
    if #cards > 2 then
    local text = "#kqf__shushen_ask"
    if to == player then text = "#kqf__shushen2_ask" end
    cards = room:askToCards(to, {
        min_num = 3,
        max_num = 3,
        include_equip = true,
        skill_name = skel.name,
        prompt = text,
        cancelable = to ~= player ,
      })
    end
    if #cards > 2 then
        --重铸3
        room:recastCard(cards, to, skel.name)
    else
        --摸3获得技能
        to:drawCards(3, skel.name)
        if player ~= to then
            room:handleAddLoseSkills(player,"-"..skel.name)
            room:handleAddLoseSkills(to,skel.name)
        end
    end
  end,

})

return skel